# This file is part of BlackArch Linux ( http://blackarch.org ).
# See COPYING for license details.

pkgname=phpstan
pkgver=13430.62841865d
pkgrel=1
pkgdesc='PHP Static Analysis Tool - discover bugs in your code without running it.'
groups=('blackarch' 'blackarch-code-audit')
arch=('any')
url='https://github.com/phpstan/phpstan'
license=('MIT')
depends=('php')
makedepends=('git')
source=("git+https://github.com/phpstan/$pkgname.git")
sha1sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  mkdir -p "$pkgdir/usr/bin"
  mkdir -p "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" *.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm *.md LICENSE

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec php $pkgname "\$@"
EOF

  chmod a+x "$pkgdir/usr/bin/$pkgname"
}

